home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / glibc-1.09 / glibc-1 / glibc-1.09.1 / sysdeps / unix / bsd / sun / sunos4 / fcntlbits.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-18  |  5.3 KB  |  146 lines

  1. /* O_*, F_*, FD_* bit values for SunOS 4.
  2. Copyright (C) 1991, 1992 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4.  
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public License as
  7. published by the Free Software Foundation; either version 2 of the
  8. License, or (at your option) any later version.
  9.  
  10. The GNU C Library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. Library General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Library General Public
  16. License along with the GNU C Library; see the file COPYING.LIB.  If
  17. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  18. Cambridge, MA 02139, USA.  */
  19.  
  20. #ifndef    _FCNTLBITS_H
  21.  
  22. #define    _FCNTLBITS_H    1
  23.  
  24.  
  25. /* File access modes for `open' and `fcntl'.  */
  26. #define    O_RDONLY    0    /* Open read-only.  */
  27. #define    O_WRONLY    1    /* Open write-only.  */
  28. #define    O_RDWR        2    /* Open read/write.  */
  29.  
  30.  
  31. /* Bits OR'd into the second argument to open.  */
  32. #define    O_CREAT        0x0200    /* Create file if it doesn't exist.  */
  33. #define    O_EXCL        0x0800    /* Fail if file already exists.  */
  34. #define    O_TRUNC        0x0400    /* Truncate file to zero length.  */
  35. #define    O_NOCTTY    0x8000    /* Don't assign a controlling terminal.  */
  36. #if    defined (__USE_BSD) || defined (__USE_SVID)
  37. #define    O_ASYNC        0x0040    /* Send SIGIO to owner when data is ready.  */
  38. #define    O_FSYNC        0x2000    /* Synchronous writes.  */
  39. #define    O_SYNC        O_FSYNC
  40. #endif
  41.  
  42. /* File status flags for `open' and `fcntl'.  */
  43. #define    O_APPEND    0x0008    /* Writes append to the file.  */
  44. #define    O_NONBLOCK    0x4000    /* Non-blocking I/O.  */
  45.  
  46. /* Sun defines O_NDELAY one way for BSD behavior and another for System V
  47.    behavior.  In the GNU C library, you get the BSD behavior unless you
  48.    define _USG_SOURCE without also defining _BSD_SOURCE or _GNU_SOURCE.  */
  49. #ifdef __USE_BSD
  50. #define    O_NDELAY    0x0004
  51. #endif
  52. #if !defined (O_NDELAY) && defined (__USE_SVID)
  53. #define    O_NDELAY    0x1000
  54. #endif
  55.  
  56. #ifdef __USE_BSD
  57. /* Bits in the file status flags returned by F_GETFL.
  58.    These are all the O_* flags, plus FREAD and FWRITE, which are
  59.    independent bits set by which of O_RDONLY, O_WRONLY, and O_RDWR, was
  60.    given to `open'.  */
  61. #define FREAD        1
  62. #define    FWRITE        2
  63.  
  64. /* Traditional Unix names the O_* bits.  */
  65. #define FASYNC        O_ASYNC
  66. #define FCREAT        O_CREAT
  67. #define FEXCL        O_EXCL
  68. #define FTRUNC        O_TRUNC
  69. #define FNOCTTY        O_NOCTTY
  70. #define FFSYNC        O_FSYNC
  71. #define FSYNC        O_SYNC
  72. #define FAPPEND        O_APPEND
  73. #define FNONBLOCK    O_NONBLOCK
  74. #define FNONBIO        O_NONBLOCK
  75. #define FNDELAY        0x0004    /* BSD O_NDELAY.  */
  76. #define    FNBIO        0x1000    /* System V O_NDELAY.  */
  77. #endif
  78.  
  79. /* Mask for file access modes.  This is system-dependent in case
  80.    some system ever wants to define some other flavor of access.  */
  81. #define    O_ACCMODE    (O_RDONLY|O_WRONLY|O_RDWR)
  82.  
  83. /* Values for the second argument to `fcntl'.  */
  84. #define    F_DUPFD          0    /* Duplicate file descriptor.  */
  85. #define    F_GETFD        1    /* Get file descriptor flags.  */
  86. #define    F_SETFD        2    /* Set file descriptor flags.  */
  87. #define    F_GETFL        3    /* Get file status flags.  */
  88. #define    F_SETFL        4    /* Set file status flags.  */
  89. #ifdef __USE_BSD
  90. #define    F_GETOWN    5    /* Get owner (receiver of SIGIO).  */
  91. #define    F_SETOWN    6    /* Set owner (receiver of SIGIO).  */
  92. #endif
  93. #define    F_GETLK        7    /* Get record locking info.  */
  94. #define    F_SETLK        8    /* Set record locking info (non-blocking).  */
  95. #define    F_SETLKW    9    /* Set record locking info (blocking).  */
  96. #ifdef    __USE_BSD
  97. #define    F_RGETLK    10    /* Get remote record locking info.  */
  98. #define    F_RSETLK    11    /* Set remote locking info (non-blocking).  */
  99. #define    F_CNVT        12    /* Convert a fhandle to an open fd.  */
  100. #define    F_RSETLKW    13    /* Set remote locking info (blocking).  */
  101. #endif
  102.  
  103. /* File descriptor flags used with F_GETFD and F_SETFD.  */
  104. #define    FD_CLOEXEC    1    /* Close on exec.  */
  105.  
  106.  
  107. #include <gnu/types.h>
  108.  
  109. /* The structure describing an advisory lock.  This is the type of the third
  110.    argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests.  */
  111. struct flock
  112.   {
  113.     short int l_type;    /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
  114.     short int l_whence;    /* Where `l_start' is relative to (like `lseek').  */
  115.     __off_t l_start;    /* Offset where the lock begins.  */
  116.     __off_t l_len;    /* Size of the locked area; zero means until EOF.  */
  117.     short int l_pid;    /* Process holding the lock.  */
  118.     short int l_xxx;    /* Reserved for future use.  */
  119.   };
  120.  
  121. #ifdef    __USE_BSD
  122. /* The structure describing a remote advisory lock.  This is the type of the
  123.    third arg to `fcntl' for the F_RGETLK, F_RSETLK, and F_RSETLKW requests.  */
  124. struct eflock
  125.   {
  126.     short int l_type;    /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
  127.     short int l_whence;    /* Where `l_start' is relative to (like `lseek').  */
  128.     __off_t l_start;    /* Offset where the lock begins.  */
  129.     __off_t l_len;    /* Size of the locked area; zero means until EOF.  */
  130.     short int l_pid;    /* Process holding the lock.  */
  131.     short int l_xxx;    /* Reserved for future use.  */
  132.     long int l_rpid;    /* Remote process ID wanting this lock.  */
  133.     long int l_rsys;    /* Remote system ID wanting this lock.  */
  134.   };
  135.  
  136. #endif
  137.  
  138.  
  139. /* Values for the `l_type' field of a `struct flock'.  */
  140. #define    F_RDLCK    1    /* Read lock.  */
  141. #define    F_WRLCK    2    /* Write lock.  */
  142. #define    F_UNLCK    3    /* Remove lock.  */
  143.  
  144.  
  145. #endif    /* fcntlbits.h */
  146.